<?php
declare (strict_types = 1);

namespace app\common\model;

use think\Model;
use think\response\Json;

/**
 * @mixin \think\Model
 */
class ProNature extends Base
{

    protected $name = 'pro_nature';
    public static function placeAdd($param)
    {
        parent::startTrans();
        try {
            $find = parent::where(array('place_id'=>$param['place_id'],'pro_id'=>$param['pro_id']))->find();
            //print_r($param);die;
            if(empty($find)){
                $param['create_time']=time();
                $param['update_time']=time();
               
                if(parent::create($param)){
                    $msg ='选择场所性质成功！';
                }
                
            }else{
            
                $param['update_time']=time();
                if($param['is_del']==1){
                    $msg='取消场所性质成功！';
                }else{
                    $msg='选择场所性质成功！';
                }
               parent::where(array('id'=>$find['id']))->update(array('is_del'=>$param['is_del']));
            }
            parent::commit();

            return ['code' => 1, 'msg' => $msg];
        } catch (\Exception $e) {
            parent::rollback();
            return ['code' => -1, 'msg' => $e->getMessage()];
        }
    }

}
